var _g;

_g = typeof self == 'object' && self.self === self && self ||
     typeof global == 'object' && global.global === global && global ||
     this ||
     {};

if(!String.prototype.format){
    String.prototype.format = function(){
        var args = arguments;
        return this.replace(/{(\d+)}/g, function(match, num){
            return typeof args[num] !== "undefined" ? args[num] : match;
        });
    };
}
if(!String.prototype.trim){
    String.prototype.trim = function(){
        return String.prototype.replace.call(this,/^\s+|\s+$/g,'');
    };
}

/**
 * 获取参数
 */
function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  decodeURI(r[2]); return null;
};

/**
 * 关于Cookie设置
 * 1.新建cookie
 * 2.读取cookies
 * 3.删除cookie
 */
var CookieHandle = {
	//新建cookie
	setCookie:function(name,value,Days){
		var exp = new Date();
		exp.setTime(exp.getTime() + Days*24*60*60*1000);
		document.cookie = name + "="+ value + ";expires=" + exp.toGMTString();
	},
	//读取cookies
	getCookie:function(name){
	    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
	    if(arr=document.cookie.match(reg))
	        return (arr[2]);
	    else
	        return null;
	},
	//删除cookie
	delCookie:function(name){
	    var exp = new Date();
	    exp.setTime(exp.getTime() - 1);
	    var cval=CookieHandle.getCookie(name);
	    if(cval!=null)
	        document.cookie= name + "="+cval+";expires="+exp.toGMTString();
	}
};
